package com.ishowcode.controller;

import com.ishowcode.Dao.Blog;
import com.ishowcode.Dao.Res;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@CrossOrigin
@RestController
public class GetBlogTitle {
    @GetMapping("/getblogt")
   public Res getblog(){
         Res<Object> res = new Res<>();
         Blog[] blogs = new Blog[5];
        Blog b1= new Blog();
        blogs[0] = b1;
        blogs[1] = b1;
        blogs[2] = b1;
        blogs[3] = b1;
        blogs[4] = b1;
        b1.setTitle("直播推流神器 Kplayer 手把手教你在B站7*24h全天直播");
        b1.setContent("##  开始前的准备工作\n" +
                "\n" +
                "  Linux服务器\n" +
                "(1)KPlayer目前仅支持Linux环境并需要满足x86_64(amd64)与aarch64(arm64)CPU架构的硬件环境上运行，我们已经将相关依赖库静态链接至主程序中，这意味着你不需要额外的安装任何的第三方库来支持KPlayer的运行。\n" +
                "在后续的迭代版本中将会陆续针对不同CPU架构与不同的操作系统上进行跨平台支持。\n" +
                "(2)这里服务器可以去主流的云平台(阿里云,腾讯云)租借一个，配置不用很高1核2g的差不多了。也可以在本地用虚拟机来当作服务器，当然你自己的主机肯定也得全天不关机，这个方法可以让一些只是想尝试一下的小伙伴用用。\n" +
                "\n" +
                "##  下载安装Kplayer\n" +
                "\n" +
                " 1. 准备一个文件夹来安装kplayer\n" +
                " 2. 进入这个文件夹\n" +
                "\t\n" +
                "\n" +
                "```bash\n" +
                "wget http://download.bytelang.cn/kplayer-v0.5.6-linux_amd64.tar.gz\n" +
                "```\n" +
                "\n" +
                "```bash\n" +
                "tar zxvf kplayer-v0.5.6-linux_amd64.tar.gz\n" +
                "```\n" +
                "3.解压完成后就算安装好了,使用命令查看\n" +
                "\n" +
                "```bash\n" +
                "./kplayer\n" +
                "```\n" +
                "\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/2021451d4b98425cb399749bf0f670ef.png#pic_center)\n" +
                "##  准备B站直播条件\n" +
                "\n" +
                " 1. 实名认证\n" +
                "这个就不用多介绍了，很简单\n" +
                " 2. 准备B站推流码\n" +
                "打开网页端B站，在首页点击直播,点击头像打开直播中心，选择我的直播间，就可以查看推流码了(当然得先选择分类然后开播才可以看到，这里先等等)\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/12d4488dfb884e458556bc67bf6e6a3c.png#pic_center)\n" +
                " 3. 创建配置文件\n" +
                " \n" +
                "\n" +
                "```bash\n" +
                "cp config.json.example config.json\n" +
                "```\n" +
                "使用cp命令复制一份配置文件\n" +
                "打开config.json文件进行编辑\n" +
                "\n" +
                "```xml\n" +
                "{\n" +
                "    \"version\": \"2.0.0\",\n" +
                "    \"resource\": {\n" +
                "        \"lists\": [\n" +
                "            \"/video/example_1.mp4\",\n" +
                "            \"/video/example_2.mp4\"\n" +
                "        ]\n" +
                "    },\n" +
                "    \"output\": {\n" +
                "        \"lists\": [\n" +
                "            {\n" +
                "                \"path\": \"rtmp://127.0.0.1:1935/push\"\n" +
                "            }\n" +
                "        ]\n" +
                "    }\n" +
                "\n" +
                "```\n" +
                "这里resource ->list列表里面配置你的视频存放的位置,注意只要不是最后一条后面要加逗号。\n" +
                "output -> list配置推流地址。\n" +
                "现在可以去选择分类然后开播了 ，然后将上面图片画的短线的地址+密钥拼接一下复制到配置文件中去,配置文件就搞定了\n" +
                "\n" +
                "##  启动kplayer\n" +
                "\n" +
                "```bash\n" +
                "./kplayer play start\n" +
                "```\n" +
                "\n" +
                "```bash\n" +
                "./kplayer play start --daemon\n" +
                "```\n" +
                "以上两个都是启动命令，下面是后台启动\n" +
                "\n" +
                "运行成功后会输出成功的日志\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/c5eeb4e110cb4fe58e9eb2edd4c7088f.png#pic_center)\n" +
                "后台运行成功后可以去/kplayer/log/core.log文件下查看运行日志\n" +
                "\n" +
                "\n" +
                "接下来就可以去你的直播间观看了\n" +
                "\n" +
                "\n" +
                "\n" +
                "欢迎各位来访问我的直播间哦  https://live.bilibili.com/26709867");
        b1.setShortContent(b1.getContent().substring(0,100)+"....");
        b1.setZhan(9999);
        res.setData(blogs);
        return res;
    }
    @GetMapping("/getBlogs")
    public Map getBlog(){
        Map<String,Blog[]> blogMap = new HashMap<>();
        Blog[] blogs = new Blog[3];
        Blog blog1 = new Blog();
        blog1.setTitle("t1");
        blog1.setContent("rfhikfhsihfiksd");
        Blog blog2 = new Blog();
        blog2.setTitle("t2");
        blog2.setContent("rfhikfhsihfiksdtertgeg");
        Blog blog3 = new Blog();
        blog3.setTitle("t3");
        blog3.setContent("rfhikfhsihfiksdsfssgsfg");
        blogs[0]=blog1;
        blogs[1]=blog2;
        blogs[2]=blog3;
        blogMap.put("blogs",blogs);
        return blogMap;
    }

}
